package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComponent;

import model.SearchContact;

public class ActionContactProp implements ActionListener {

	@Override
	public void actionPerformed(ActionEvent e) {
		String b = ((JButton) e.getSource()).getName();
		int id = Integer.valueOf(((JButton) e.getSource()).getComponent(0).getName());
		switch (b) {
		case "rimuovi": {
			Engine.closeContactProp(id);
			Engine.rimuoviContatto(id);
			// HomeContact.search.setText("");
			SearchContact.cnt.updateForUser();
			break;
		}
		case "aggiungi": {
			Engine.closeContactProp(id);
			Engine.aggiungiContatto(id);
			// HomeContact.search.setText("");
			SearchContact.cnt.updateForUser();
			break;
		}
		case "aggiungi_1": {
			Engine.closeContactProp(id);
			Engine.aggiungiContatto(id);
			// HomeContact.search.setText("");
			SearchContact.cnt.updateForUser();
			break;
		}
		case "chiudi":{
			Engine.closeContactProp(id);
			SearchContact.cnt.updateForUser();
			break;
		}
		}
		((JComponent) e.getSource()).requestFocus();
	}
}
